package cn.tedu.file;

import java.io.*;

/**本类用于字符输入流*/
public class TestIn2 {
    public static void main(String[] args) {
        method1();//使用普通字符输入流读取
        method2();//使用高效字符输入流读取
    }

    private static void method2() {
        BufferedReader in = null;
        try{
//            in = new BufferedReader(new FileReader(new File("C:\\kaifa\\ready\\1.1txe")));
            in = new BufferedReader(new FileReader("C:\\kaifa\\ready\\1.1txe"));
            int b;
            while((b = in.read())!=-1){
                System.out.println(b);
            }
        }catch(Exception e){
            e.fillInStackTrace();
        }finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

    private static void method1() {
        FileReader in = null;
        try {
//            FileReader in2 = new FileReader(new File("C:\\kaifa\\ready\\1.txt"));
            in = new FileReader("C:\\kaifa\\ready\\1.txt");
            int b;
            while((b = in.read())!=-1){
                System.out.println(b);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
